#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
int* plusOne(int* digits, int digitsSize){
	int flag = 0; int count = digitsSize;
	while (digitsSize)
	{
		//zhao 9
		if (digits[digitsSize - 1] == 9)
		{
			digitsSize--;
			flag = 1;
			
		}
		else
			break;
	}
	if (digitsSize == 0)
	{
		int* arr = (int*)malloc((count + 1)* sizeof(int));
		arr[0] = 1;
		for (int i = 1; i <= count; i++)
		{
			arr[i] = 0;
		}
		return arr;
	}
	else if(flag)
	{
		digits[digitsSize] = 0;
		digits[digitsSize - 1]++;
		return digits;
	}
	else
	{
		digits[digitsSize - 1]++;
		return digits;
	}

}
